Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
How to fix "Uncaught TypeError: db.collection is not a function"?

code in which the error occurs:

const countRef = db.collection('counter').doc('counter');
const increment = firebase.Firestore.FieldValue.increment(1);
const decrement = firebase.Firestore.FieldValue.increment(-1);
function change(num) {
    if (num>0) {
        countRef.update({ counter: increment });
    } else if (num<0) {
        countRef.update({ counter: decrement });
    };
};

The error is in the first line of code. I have also tried to search the internet for answers, but I have not yet found any.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As you haven't shown what db is defined to, this answer may be incorrect/not help.


The issue seems to be that you are setting db to an object which doesn't have collection().

Make sure that the db variable is defined and set to the following:

const db = firebase.firestore();

This object has the collection() method defined in it, which may fix the issue.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda